(*
   Copyright (c) 2022-2025 Semgrep Inc.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public License
   version 2.1 as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
   LICENSE for more details.
*)
(*****************************************************************************)
(* types *)
(*****************************************************************************)

type language = C | Cplusplus

(*****************************************************************************)
(* macros *)
(*****************************************************************************)

let macros_h =
  ref
    (Fpath.v
       (match Sys.win32 with
       (* Windows doesn't like paths that start with / *)
       (* So provide a default path that may exist in windows *)
       | true -> "C:/Program Files/LLVM/include/c++/v1/macros.h"
       | false -> "/data/cpp_stdlib/macros.h"))

let cmdline_flags_macrofile () =
  [
    ( "-macros",
      Arg.String (fun s -> macros_h := Fpath.v s),
      " <file> list of macros to expand" );
  ]

(*****************************************************************************)
(* verbose *)
(*****************************************************************************)

let filter_msg = ref false
let filter_classic_passed = ref false
let filter_define_error = ref true

(*****************************************************************************)
(* debugging *)
(*****************************************************************************)

(* TODO: switch to Log_parser_cpp, or design new Log srcs for each of those
 * category
 *)
let debug_typedef = ref true
let debug_pp = ref true
let debug_cplusplus = ref true

let cmdline_flags_debugging () =
  [
    ("-no_debug_pp", Arg.Clear debug_pp, " ");
    ("-no_debug_typedef", Arg.Clear debug_typedef, "  ");
    ("-no_debug_cplusplus", Arg.Clear debug_cplusplus, " ");
    ( "-debug_cpp",
      Arg.Unit
        (fun () ->
          debug_pp := true;
          debug_typedef := true;
          debug_cplusplus := true),
      " " );
  ]
